<template>
  <div class="detailCardStyle">
    <el-card class="box-card" shadow="never"  :class="showContent ? '' : 'noPaddingBottom'">
      <div slot="header" class="clearfix" style="font-size: 14px;">
        <slot name="header"></slot>
        <slot name="headerLeft"></slot>
        <el-button
          v-if="hideContentDefault"
          type="text"
          @click="toggleFlag"
          :icon="showContent?'el-icon-arrow-up':'el-icon-arrow-down'"
          style="float: right;padding: 0;position: relative;top: 3px;"
        >{{showContent?$t('fold'):$t('unfold')}}</el-button>
        <p style="float: right;padding-right: 10px;"><slot name="headerRight"></slot></p>
      </div>
      <slot name="alwaysShowContent"></slot>
      <el-collapse-transition>
        <div v-if="showContent" :class="showScrollBar ? 'overflowAuto' : ''">
          <slot name="content"></slot>
        </div>
      </el-collapse-transition>
    </el-card>
  </div>
</template>
<script>
export default {
  name: 'DetailBox',
  props: {
    hideContentDefault: {
      type: Boolean,
      default: false
    },
    showScrollBar: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      showContent: !this.hideContentDefault
    }
  },
  methods: {
    toggleFlag () {
      this.showContent = !this.showContent
      this.$emit('nowFlag', this.showContent)
    }
  }
}
</script>
<style lang="scss" scoped>
.detailCardStyle {
  margin-top: 20px;
  &:first-child {
    margin-top: 0;
  }
  .box-card {
    width: 100%;
    border-radius: 0;
    border-color: #E3E3E3;
    overflow-y: auto;
  }
  .clearfix {
    font-weight: bold;
  }
  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both;
  }
  /deep/ .el-card {
    box-shadow: 0px 2px 12px -4px rgba(0,0,0,0.15);
    color: #4f4f4f;
    .el-card__header {
      height: 50px;
      width: 100%;
      background-color: #fff;
      padding: 15px 5px !important;
      margin: 0 15px 0 15px;
      width: calc(100% - 30px) !important;
    }
    .noPaddingBottom {
      .el-card__body {
        padding-bottom: 0;
      }
    }
    .detailBoxStyle .box-card {
      max-height: fit-content;
    }
    .el-timeline-item__content {
      color: #909399;
    }
    .detailBoxStyle .box-card {
      border-color: #909399;
    }
    hr {
      border: 0;
      border-top: #909399 solid 1px;
    }
    .el-form-item__label {
      color: #909399;
      font-size: 12px;
    }
    .el-form-item__content {
      font-size: 12px;
      color: #909399;
    }
  }
}
</style>
